const path = require('path');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {DefinePlugin} = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
    entry:'./src/js/es_index.js',
    output:{
        path:path.resolve(__dirname,'./dist'),
        filename:'bundle.js'
    },
    mode:'development',
    devtool:'source-map',
    module:{
        rules:[
            {
               test:/\.css$/,
               use:['style-loader','css-loader']
            },
            {  
                test: /\.ts$/, 
                use: 'ts-loader' 
            }
        ]
    },
    plugins:[
        new CleanWebpackPlugin(),
        new HtmlWebpackPlugin({
            title:'webpack003',
            template:'./public/index.html'
        }),
        new DefinePlugin({
            BASE_URL:'"./"'
        }),
        new CopyPlugin({
            patterns:[{
                from:'public',
                globOptions:{
                ignore:[
                    '**/.DS_Store',
                    '**/index.html'
                ]
               }
            }]
        })
    ]
}